using System;
using System.Configuration;
using System.Globalization;

namespace X.Ray.Core.Framework
{
    public static class ConfigHelper
    {
        public static bool GetBoolProperty(string key, bool defaultValue)
        {
            string setting = ConfigurationManager.AppSettings[key];
            if (setting == null) return defaultValue;
            switch (setting.ToLower(CultureInfo.InvariantCulture))
            {
                case "true":
                    return true;
                case "false":
                    return false;
                default:
                    return defaultValue;
            }
        }

        public static int GetIntProperty(string key, int defaultValue)
        {
            int setting;
            return int.TryParse(ConfigurationManager.AppSettings[key], out setting) ? setting : defaultValue;
        }

    }
}
